<template>
	<view class="content">
		<view class="list">
			<input class="input" type="text" placeholder="请输入昵称" v-model="nickname" maxlength="14"/>
		</view>
		
		<view class="submit" @click="change">确认</view>
		
	</view>
</template>

<script>
	import api from "../../../../../common/api/api.js"
	export default {
		data() {
			return {
				nickname:''
			}
		},
		methods: {
			// 设置昵称
			change: function () {
				let that = this;
				if (that.nickname == '') {
					that.tui.toast('请输入昵称');
					return
				}
				api.changeUsewrInfo({
					nickname:that.nickname
				}).then(res => {
					console.log(res)
					// that.tui.toast(res.msg)
					uni.showToast({
						title:res.msg,
						icon:"none"
					})
					setTimeout(function () {
						// that.cacheHelper.updateUserInfo();
						uni.$emit('login',{msg:'更新信息'})
					},500)
					setTimeout(function () {
						uni.navigateBack({
							delta: 2
						});
					},1500)
				})
				
			}
			 
		}
	}
</script>

<style lang="less">
	page {
		width: 100%;
		box-sizing: border-box;
		letter-spacing: 3rpx;
		background: #F5F5F5;
		font-family: PingFang SC;
		padding: 20rpx 0;
		font-size: 30rpx;
		color: #140005;
	}
	.content {
		width: 100%;
		box-sizing: border-box;
	}
	.list {
		width: 100%;
		box-sizing: border-box;
		background: #FFFFFF;
		padding: 20rpx 30rpx;
		.input {
			width: 100%;
			box-sizing: border-box;
			height: 60rpx;
			line-height: 60rpx;
		}
	}
	.submit {
		width: 650rpx;
		box-sizing: border-box;
		text-align: center;
		line-height: 94rpx;
		background: #E42221;
		color: #FFFFFF;
		margin: 150rpx auto 20rpx auto;
		border-radius: 8rpx;
	}

</style>
